//
//  SGCorePayment.h
//  smartGas
//
//  Created by chen on 2017/11/20.
//  Copyright © 2017年 chen. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "BaseModel.h"

#import "AppPaymentMacro.h"


typedef enum : NSUInteger {
    SGCorePaymentTypeRecharge = 1, //充值
    SGCorePaymentTypeRefund = 2, //退款
    SGCorePaymentTypePayment = 3, //支付
} SGCorePaymentType;


typedef enum : NSUInteger {
    SGCorePaymentGoodsTypeRecharge = 1, //充值
    SGCorePaymentGoodsTypeBuyOil   = 2, //买油
} SGCorePaymentGoodsType;


/**
 生成的微信订单模型
 */
@interface SGGeneratedWeixinPayModel : BaseModel
@property(nonatomic,copy)NSString * partnerId;
@property(nonatomic,copy)NSString * prepayId;
@property(nonatomic,copy)NSString * nonceStr;
@property(nonatomic,copy)NSString * timeStamp;
@property(nonatomic,copy)NSString * sign;
@end


@interface SGCorePayment : NSObject

#pragma mark - 微信支付

/**
 发起微信支付
 
 @param partnerId 商家id
 @param prepayId 预支付订单
 @param nonceStr 随机串，防重发
 @param timeStamp 时间戳，防重发
 @param sign 数据签名
 */
+ (void)wxPayWithPartnerId:(NSString *)partnerId
                  prepayId:(NSString *)prepayId
                  nonceStr:(NSString *)nonceStr
                 timeStamp:(UInt32)timeStamp
                      sign:(NSString *)sign;

/**微信支付测试使用*/
+ (void)wxPayTest DEPRECATED_MSG_ATTRIBUTE("不会支付成功,请使用`wxPayWithPartnerId:prepayId:nonceStr:timeStamp:sign:`方法");;



/**
 微信生成订单

 @param userId 用户id
 @param amount 价格 。单位元，最多保留两位小数
 @param paymentType 交易类型
 @param goosType 商品类型
 @param relationId 关联订单id，充值时传空字符串
 @param success 成功
 @param failed 失败
 */
+ (void)wxGeneratePaymentWithUserId:(NSString *)userId
                             amount:(NSString *)amount
                               type:(SGCorePaymentType)paymentType
                          goodsType:(SGCorePaymentGoodsType)goodsType
                         relationId:(NSString *)relationId
                            success:(void(^)(SGGeneratedWeixinPayModel *model,NSString *des))success
                             failed:(void(^)(NSError *error, NSString *des))failed;


@end


